<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="vue.js"></script>
    <title>Vue 组件</title>
</head>
<body>
    <div id="app">

        <button-counter title="title1" @clicknow="clicknow "></button-counter>
    </div>
    <script>
        Vue.component("button-counter",{
            props:['title'],
            data:function(){
                return {
                    count:0
                }
            },
         
            template: '<button v-on:click="clickfun" >you click me {{count}}</button>',
            methods:{
                clickfun: function(){
                     this.count ++;
                    this.$emit('clicknow',this.count)
                }
            }
            

        })
        var vm =new Vue({
            el:'#app',
            data:{

            },
            methods:{
                clicknow: function(e){
                    console.log(e)
                }
            }
        })
    </script>
</body>
</html>